(*%F _fdata *)
(*# call(seg_name => null) *)
(*%E *)
(*# module(implementation=>off) *)
(*# data(seg_name => null) *)
(*# call(o_a_copy => off) *)
(*# check(stack=>off,
          index=>off,
          range=>off,
          overflow=>off,
          nil_ptr=>off) *)

DEFINITION MODULE NFIO;

(* A module for JPI Topspeed Modula-2 *)
(* By Carl Neiburger
   169 N. 25th St.
   San Jose, Calif.

   CompuServe No. 72336,2257

NOTE: THIS IS AN ABRIDGED VERSION OF NFIO THAT INCLUDES
PROCEDURES NEEDED FOR FILE TRANSFER PROTOCOLS

*)

IMPORT FioAsm;

TYPE
  File = CARDINAL;

CONST
  MaxOpenFiles = 15;

  readonly = FioAsm.readonly;
  hidden   = FioAsm.hidden;
  system   = FioAsm.system;
  volume   = FioAsm.volume;
  directory = FioAsm.directory;
  archive  = FioAsm.archive;

TYPE
  PathStr  =  FioAsm.PathStr;
  PathTail =  FioAsm.PathTail;

(*
PROCEDURE IOresult() : CARDINAL;
These procedures set IOresult and return MAX(CARDINAL) if they fail:
*)
PROCEDURE Create(Name: ARRAY OF CHAR) : File;
PROCEDURE Open  (Name: ARRAY OF CHAR) : File;

(* These procedures check IOresult and set OK *)
PROCEDURE Size  (F: File) : LONGCARD;
PROCEDURE EOF (F:File): BOOLEAN;
PROCEDURE ChDir (Name: ARRAY OF CHAR);
PROCEDURE Rename(Name,NewName : ARRAY OF CHAR);
PROCEDURE GetPos(F: File) : LONGCARD;
PROCEDURE Erase (Name: ARRAY OF CHAR);
PROCEDURE Close (F: File);

(* These procedures do not set IOresult: *)

PROCEDURE Exists(Name: ARRAY OF CHAR) : BOOLEAN;
PROCEDURE GetDir(Drive: SHORTCARD; VAR Name: ARRAY OF CHAR);

(* These procedures set OK to false if IOresult <> 0 *)

PROCEDURE WrBin    (F: File; Buf: ARRAY OF BYTE; Count: CARDINAL);

PROCEDURE RdChar   (F: File) : CHAR;
PROCEDURE RdStr    (F: File; VAR V: ARRAY OF CHAR);
PROCEDURE RdBin    (F: File; VAR Buf: ARRAY OF BYTE; Count: CARDINAL) : CARDINAL;

VAR OK          : BOOLEAN;

CONST

  IOresult = FioAsm.IOresult;
  Write = FioAsm.Write;
  Read = FioAsm.Read;
END NFIO.
